package com.blacksheep.mtm.dao;

import com.blacksheep.mtm.dto.OrderDtoSimple;
import com.blacksheep.mtm.dto.OrderExcelDto;
import com.blacksheep.mtm.dto.front.OrderFrontDto;
import com.blacksheep.mtm.dto.report.OrderReport;
import com.blacksheep.mtm.dto.report.OrderReportCustomerCount;
import com.blacksheep.mtm.pojo.manager.TbOrder;
import com.blacksheep.mtm.pojo.manager.TbOrderExample;

import java.util.Date;
import java.util.List;

import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;

public interface TbOrderMapper {
    long countByExample(TbOrderExample example);

    int deleteByExample(TbOrderExample example);

    int deleteByPrimaryKey(String orderId);

    int insert(TbOrder record);

    int insertSelective(TbOrder record);

    List<TbOrder> selectByExample(TbOrderExample example);

    TbOrder selectByPrimaryKey(String orderId);

    int updateByExampleSelective(@Param("record") TbOrder record, @Param("example") TbOrderExample example);

    int updateByExample(@Param("record") TbOrder record, @Param("example") TbOrderExample example);

    int updateByPrimaryKeySelective(TbOrder record);

    int updateByPrimaryKey(TbOrder record);

    List<OrderFrontDto> selectList(@Param("search") String search, @Param("state") int[] state, @Param("minDate") String minDate,
                                   @Param("maxDate") String maxDate, @Param("orderCol") String orderCol,
                                   @Param("orderDir") String orderDir);
    List<OrderFrontDto> selectListDto(@Param("search") String search, @Param("state") int[] state,@Param("isPrint") int isPrint, @Param("minDate") String minDate,
                                   @Param("maxDate") String maxDate, @Param("orderCol") String orderCol,
                                   @Param("orderDir") String orderDir);

    List<OrderFrontDto> selectCancelListDto(@Param("search") String search, @Param("minDate") String minDate,
                                      @Param("maxDate") String maxDate, @Param("orderCol") String orderCol,
                                      @Param("orderDir") String orderDir);

    int updateCCidByPrimaryKey(@Param("orderId") String[] orderId,@Param("id") Long id);
    int updateDispenserIdByPrimaryKey(@Param("orderId")String[] orderId,@Param("id") Long id);
    int updateDispatcherIdByPrimaryKey(@Param("orderId")String[] orderId,@Param("id") Long id);
    int updateReserveTimeByPrimaryKey(@Param("orderId")String orderId, @Param("reserveTime")Date reserveTime);
    int reviewOrderByPrimaryKey(@Param("orderId")String orderId);

    int cancelOrderByPrimaryKey(String orderId);

    List<TbOrder> selectListByCondition(@Param("memberId") Long memberId,@Param("search") String search,@Param("state") Integer[] state);

    /**
     * 根据配下单人id和状态查找订单
     * @param memberId
     * @return
     */
    List<OrderDtoSimple> selectOrderDtoListByMemberId(@Param("memberId") Integer memberId,@Param("state") Integer[] state);

    /**
     * 根据订单id和下单人id查找订单
     * @param orderId
     * @param memberId
     * @return
     */
    TbOrder selectOrderDtoByOrderId(@Param("orderId") String orderId,@Param("memberId") Integer memberId);

    /**
     * 根据配送员id和状态查找订单
     * @param memberId
     * @param state
     * @return
     */
    List<OrderDtoSimple> selectDtoSimpleListByMemberId(@Param("memberId") Integer memberId,@Param("state") Integer state);

    /**
     * 根据订单id 和 配送员id查找订单
     * @param orderId
     * @param memberId
     * @return
     */
    TbOrder selectOrderDtoByOrderIdAndDeliveryId(@Param("orderId") String orderId,@Param("memberId") Integer memberId);


    int updateStateByPrimaryKey(@Param("orderId")String orderId,@Param("state") Integer state);



    List<OrderExcelDto> selectDownloadList(@Param("state") int[] state, @Param("minDate") String minDate,
                                           @Param("maxDate") String maxDate);

    int updatePrintStateById(@Param("orderId")String orderId,@Param("printState") Integer state);

    TbOrder selectPrintStateById(@Param("orderId")String orderId);

    int selectCountByState(@Param("state")Integer[] state);


    //下单人下单数量报表
    List<OrderReport> selectOrderReport(@Param("search") String search,@Param("minDate") String minDate,
                                        @Param("maxDate") String maxDate,@Param("orderCol") String orderCol,
                                        @Param("orderDir") String orderDir);

    List<OrderReportCustomerCount> selectMemberCustomerCount(@Param("isNew")int isNew,@Param("minDate") String minDate,
                                                             @Param("maxDate") String maxDate);

}